package com.example.produce.controller;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
public class HelloSender {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @RequestMapping(value = "/send")
    public String send() {
        String context = "hello " + new Date();
        System.out.println("Sender : " + context);
     //   this.rabbitTemplate.convertAndSend("hello", context);
        rabbitTemplate.convertAndSend("Exchange","",context);
        return "ok";
    }

}